#! /usr/bin/python
import sys
import numpy
from math import isnan

(last_key, values) = (None, None)
Abbrs=[]
SSs=[]
maxTi = sys.float_info.min
minTi = sys.float_info.max


print "KEY, AVG_SS, AVG_ABBR, MIN_TI, MAX_TI"
for line in sys.stdin:
    (key, values) = line.strip().split("\t")
    
    if last_key and last_key != key:
        print "%s, %f, %f, %f, %f" % (last_key, numpy.mean(SSs), numpy.mean(Abbrs), minTi, maxTi)
        Abbrs=[]
        SSs=[]
        maxTi = sys.float_info.min
        minTi = sys.float_info.max
  
        
    values = values.split(" ")
    SS=float(values[0])
    Abbr=float(values[1])
    Ti = float (values[2])
    
    if (Ti < minTi): minTi = Ti
    if (Ti > maxTi): maxTi = Ti
    
    Abbrs.append(Abbr)
    if not isnan(SS) and SS > 0:
        SSs.append(SS)      
    last_key = key
    
if last_key:
    print "%s, %f, %f, %f, %f" % (last_key, numpy.mean(SSs), numpy.mean(Abbrs), minTi, maxTi)
